﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Devonline.Core;

namespace Devonline.Entity
{
    /// <summary>
    /// 字符串类型的默认基类
    /// </summary>
    public abstract class EntitySet : EntitySet<string>
    {
    }

    /// <summary>
    /// 基础数据对象模型抽象基类
    /// </summary>
    public abstract class EntitySet<TKey> : IEntitySet<TKey> where TKey : IConvertible
    {
        /// <summary>
        /// 构造方法给 Id 赋值
        /// </summary>
        public EntitySet()
        {
            Id = KeyGenerator.GetKey<TKey>();
        }

        /// <summary>
        /// 数据主键
        /// </summary>
        [Column("id"), DisplayName("编号"), DatabaseGenerated(DatabaseGeneratedOption.None), Key, MaxLength(36), Excel]
        public virtual TKey Id { get; set; }
    }
}
